package com.gzdh.dishrecognition.config;

import android.content.Context;
import android.content.SharedPreferences;

import com.gzdh.dishrecognition.AppContext;
import com.gzdh.dishrecognition.emu.CardSectorPassEmus;
import com.gzdh.dishrecognition.emu.ModelEmus;
import com.gzdh.dishrecognition.emu.OfflineGetCardSnTypeEmus;
import com.gzdh.dishrecognition.emu.PeripheralDeviceEmus;
import com.gzdh.dishrecognition.emu.PrintDevEmus;
import com.gzdh.dishrecognition.emu.ReadCardTypeEmus;

public class SysConstConfig {
    private static SysConstConfig sysConstConfig;

    public static SysConstConfig getInstance() {
        if (sysConstConfig == null) {
            sysConstConfig = new SysConstConfig();
        }
        return sysConstConfig;
    }

    private SharedPreferences sharedPreferences;

    private SharedPreferences.Editor editor;

    public SysConstConfig() {
        sharedPreferences = AppContext.getInstance().getSharedPreferences("systemI", Context.MODE_PRIVATE); //私有数据
        editor = sharedPreferences.edit();
        hideDinner = sharedPreferences.getBoolean("hideDinner", false);
        autoDinner = sharedPreferences.getBoolean("autoDinner", false);
        kuacan = sharedPreferences.getBoolean("kuacan", false);
        scanTake = sharedPreferences.getBoolean("scanTake", false);
        allowPreDin = sharedPreferences.getBoolean("allowPreDin", false);
        successClose = sharedPreferences.getBoolean("successClose", false);
        errorClose = sharedPreferences.getBoolean("errorClose", false);
        errorCloseSec = sharedPreferences.getInt("errorCloseSec", 5);
        successCloseSec = sharedPreferences.getInt("successCloseSec", 5);

        allowWeixin = sharedPreferences.getBoolean("allowWeixin", false);
        allowAli = sharedPreferences.getBoolean("allowAli", false);
        allowCard = sharedPreferences.getBoolean("allowCard", true);
        allowCash = sharedPreferences.getBoolean("allowCash", true);
        allowElectronicCard = sharedPreferences.getBoolean("allowElectronicCard", true);

//        surfaceModel = sharedPreferences.getInt("surfaceModel", 0);
//        surfaceModel.setValue(sharedPreferences.getInt("surfaceModel", 0));
        surfaceModel = ModelEmus.getByValue(sharedPreferences.getInt("surfaceModel", 0));
        peripheralDeviceModel = PeripheralDeviceEmus.getByValue(sharedPreferences.getInt("peripheralDeviceModel", 1));
        foodsMenuRow = sharedPreferences.getInt("foodsMenuRow", 4);
        foodsMenuTextSize = sharedPreferences.getInt("foodsMenuTextSize", 23);
        foodsMenuInternalLine = sharedPreferences.getInt("foodsMenuInternalLine", 3);
        foodsMenuInternalPriceSize = sharedPreferences.getInt("foodsMenuInternalPriceSize", 16);
        scanTakeFontSize = sharedPreferences.getInt("scanTakeFontSize", 16);
        shopCartFontSize = sharedPreferences.getInt("shopCartFontSize", 24);
        deviceType = sharedPreferences.getInt("deviceType", 0);

        deviceReportFontSize = sharedPreferences.getInt("deviceReportFontSize", 15);
        isUseRefundBtn = sharedPreferences.getBoolean("isUseRefundBtn", true);

        freeInputAmountFontSize = sharedPreferences.getInt("freeInputAmountFontSize", 150);
        freeTotalAmountFontSize = sharedPreferences.getInt("freeTotalAmountFontSize", 50);
        isShowRightKeyboard = sharedPreferences.getBoolean("isShowRightKeyboard", true);
        rightKeyboardDisplaySize = sharedPreferences.getInt("rightKeyboardDisplaySize", 0);
        inputNumberBottomButtonSize = sharedPreferences.getInt("inputNumberBottomButtonSize", 0);

        readCardType = ReadCardTypeEmus.getByValue(sharedPreferences.getInt("readCardType", 0));
        offlineGetCardSnType = OfflineGetCardSnTypeEmus.getByValue(sharedPreferences.getInt("offlineGetCardSnType", 0));
        cardDataSector = sharedPreferences.getInt("cardDataSector", 0);
        cardSectorPass = CardSectorPassEmus.getByValue(sharedPreferences.getInt("cardSectorPass", 0));

        printDevEmus = PrintDevEmus.getByValue(sharedPreferences.getInt("printDev", 0));
        printTextSize = sharedPreferences.getInt("printTextSize", 0);
        printWidthPixel = sharedPreferences.getInt("printWidthPixel", 384);
        printMiddleLocation = sharedPreferences.getInt("printMiddleLocation", 192);
        printProductNameEnter = sharedPreferences.getInt("printProductNameEnter", 192);
        fixedAmount = sharedPreferences.getString("fixedAmount", "0.00");
        fixedAutoPay = sharedPreferences.getBoolean("fixedAutoPay", false);
        autoLogin = sharedPreferences.getBoolean("autoLogin", true);
        user = sharedPreferences.getString("user", "");
        pos = sharedPreferences.getString("pos", "");
    }

    //隐藏餐次
    private boolean hideDinner;

    //自动餐次
    private boolean autoDinner;

    //允许跨餐次
    private boolean kuacan;

    private boolean scanTake;

    //副屏点餐
    private boolean allowPreDin;

    //支付成功自动关闭
    private boolean successClose;

    //支付失败自动关闭
    private boolean errorClose;

    private boolean onLinePay;

    private boolean autoLogin;

    private int errorCloseSec;

    private int successCloseSec;

    private boolean allowWeixin;

    private boolean allowAli;

    private boolean allowCard;

    private boolean allowCash;

    private boolean allowElectronicCard;

    private ModelEmus surfaceModel;
    //外围设备
    private PeripheralDeviceEmus peripheralDeviceModel;

    private int foodsMenuTextSize;

    private int foodsMenuRow;

    private int foodsMenuInternalLine;

    private int foodsMenuInternalPriceSize;

    private int scanTakeFontSize;

    private int shopCartFontSize;

    private int deviceType;

    private ReadCardTypeEmus readCardType;

    private OfflineGetCardSnTypeEmus offlineGetCardSnType;

    private int cardDataSector;


    private CardSectorPassEmus cardSectorPass;

    private PrintDevEmus printDevEmus;

    private int printTextSize;

    private int printWidthPixel;

    private int printMiddleLocation;

    private int printProductNameEnter;

    private String fixedAmount;

    private boolean fixedAutoPay;

    private String user;

    private String pos;

    private int deviceReportFontSize;

    private boolean isUseRefundBtn;

    private int freeInputAmountFontSize;

    private int freeTotalAmountFontSize;

    private boolean isShowRightKeyboard;

    private int rightKeyboardDisplaySize;

    private int inputNumberBottomButtonSize;

    public String getPos() {
        return pos;
    }

    public void setPos(String pos) {
        this.pos = pos;
        editor.putString("pos", pos);
        editor.apply();
    }

    public int getDeviceType() {
        return deviceType;
    }

    public void setDeviceType(int deviceType) {
        this.deviceType = deviceType;
        editor.putInt("deviceType", deviceType);
        editor.apply();
    }

    public int getFoodsMenuInternalPriceSize() {
        return foodsMenuInternalPriceSize;
    }

    public void setFoodsMenuInternalPriceSize(int foodsMenuInternalPriceSize) {
        this.foodsMenuInternalPriceSize = foodsMenuInternalPriceSize;
        editor.putInt("foodsMenuInternalPriceSize", foodsMenuInternalPriceSize);
        editor.apply();
    }

    public int getScanTakeFontSize() {
        return scanTakeFontSize;
    }

    public void setScanTakeFontSize(int scanTakeFontSize) {
        this.scanTakeFontSize = scanTakeFontSize;
        editor.putInt("scanTakeFontSize", scanTakeFontSize);
        editor.apply();
    }

    public int getShopCartFontSize() {
        return shopCartFontSize;
    }

    public void setShopCartFontSize(int shopCartFontSize) {
        this.shopCartFontSize = shopCartFontSize;
        editor.putInt("shopCartFontSize", shopCartFontSize);
        editor.apply();
    }

    public int getFoodsMenuInternalLine() {
        return foodsMenuInternalLine;
    }

    public void setFoodsMenuInternalLine(int foodsMenuInternalLine) {
        this.foodsMenuInternalLine = foodsMenuInternalLine;
        editor.putInt("foodsMenuInternalLine", foodsMenuInternalLine);
        editor.apply();
    }

    public int getFoodsMenuTextSize() {
        return foodsMenuTextSize;
    }

    public void setFoodsMenuTextSize(int foodsMenuTextSize) {
        this.foodsMenuTextSize = foodsMenuTextSize;
        editor.putInt("foodsMenuTextSize", foodsMenuTextSize);
        editor.apply();
    }

    public int getFoodsMenuRow() {
        return foodsMenuRow;
    }

    public void setFoodsMenuRow(int foodsMenuRow) {
        this.foodsMenuRow = foodsMenuRow;

        editor.putInt("foodsMenuRow", foodsMenuRow);
        editor.apply();
    }

    public PeripheralDeviceEmus getPeripheralDeviceModel() {
        return peripheralDeviceModel;
    }

    public void setPeripheralDeviceModel(PeripheralDeviceEmus peripheralDeviceModel) {
        this.peripheralDeviceModel = peripheralDeviceModel;
        editor.putInt("peripheralDeviceModel", peripheralDeviceModel.getValue());
        editor.apply();
    }

    public ModelEmus getSurfaceModel() {
        return surfaceModel;
    }

    public void setSurfaceModel(ModelEmus surfaceModel) {
        this.surfaceModel = surfaceModel;
        editor.putInt("surfaceModel", surfaceModel.getValue());
        editor.apply();
    }

    public boolean isAllowWeixin() {
        return allowWeixin;
    }

    public void setAllowWeixin(boolean allowWeixin) {
        this.allowWeixin = allowWeixin;
        editor.putBoolean("allowWeixin", allowWeixin);
        editor.apply();
    }

    public boolean isAllowAli() {
        return allowAli;
    }

    public void setAllowAli(boolean allowAli) {
        this.allowAli = allowAli;
        editor.putBoolean("allowAli", allowAli);
        editor.apply();
    }

    public boolean isAutoLogin() {
        return autoLogin;
    }

    public void setAutoLogin(boolean autoLogin) {
        this.autoLogin = autoLogin;
        editor.putBoolean("autoLogin", autoLogin);
        editor.apply();
    }


    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
        editor.putString("user", user);
        editor.apply();
    }

    public boolean isAllowCard() {
        return allowCard;
    }

    public void setAllowCard(boolean allowCard) {
        this.allowCard = allowCard;
        editor.putBoolean("allowCard", allowCard);
        editor.apply();
    }

    public boolean isAllowCash() {
        return allowCash;
    }

    public void setAllowCash(boolean allowCash) {
        this.allowCash = allowCash;
        editor.putBoolean("allowCash", allowCash);
        editor.apply();
    }

    public boolean isAllowElectronicCard() {
        return allowElectronicCard;
    }

    public void setAllowElectronicCard(boolean allowElectronicCard) {
        this.allowElectronicCard = allowElectronicCard;
        editor.putBoolean("allowElectronicCard", allowElectronicCard);
        editor.apply();
    }

    public int getErrorCloseSec() {
        return errorCloseSec;
    }

    public void setErrorCloseSec(int errorCloseSec) {
        this.errorCloseSec = errorCloseSec;
        editor.putInt("errorCloseSec", errorCloseSec);
        editor.apply();
    }

    public int getSuccessCloseSec() {
        return successCloseSec;
    }

    public void setSuccessCloseSec(int successCloseSec) {
        this.successCloseSec = successCloseSec;
        editor.putInt("successCloseSec", successCloseSec);
        editor.apply();
    }

    public boolean isHideDinner() {
        return hideDinner;
    }

    public void setHideDinner(boolean hideDinner) {
        this.hideDinner = hideDinner;
        editor.putBoolean("hideDinner", hideDinner);
        editor.apply();
    }

    public boolean isAutoDinner() {
        return autoDinner;
    }

    public void setAutoDinner(boolean autoDinner) {
        this.autoDinner = autoDinner;
        editor.putBoolean("autoDinner", autoDinner);
        editor.apply();
    }


    public boolean isKuacan() {
        return kuacan;
    }

    public void setKuacan(boolean kuacan) {
        this.kuacan = kuacan;
        editor.putBoolean("kuacan", kuacan);
        editor.apply();
    }

    public boolean isScanTake() {
        return scanTake;
    }

    public void setScanTake(boolean scanTake) {
        this.scanTake = scanTake;
        editor.putBoolean("scanTake", scanTake);
        editor.apply();
    }

    public boolean isAllowPreDin() {
        return allowPreDin;
    }

    public void setAllowPreDin(boolean allowPreDin) {
        this.allowPreDin = allowPreDin;
        editor.putBoolean("allowPreDin", allowPreDin);
        editor.apply();
    }

    public boolean isSuccessClose() {
        return successClose;
    }

    public void setSuccessClose(boolean successClose) {
        this.successClose = successClose;
        editor.putBoolean("successClose", successClose);
        editor.apply();
    }

    public boolean isErrorClose() {
        return errorClose;
    }

    public void setErrorClose(boolean errorClose) {
        this.errorClose = errorClose;
        editor.putBoolean("errorClose", errorClose);
        editor.apply();
    }

    public boolean isOnLinePay() {
        return onLinePay;
    }

    public void setOnLinePay(boolean onLinePay) {
        this.onLinePay = onLinePay;
    }

    public ReadCardTypeEmus getReadCardType() {
        return readCardType;
    }

    public void setReadCardType(ReadCardTypeEmus readCardType) {
        this.readCardType = readCardType;
        editor.putInt("readCardType", readCardType.getValue());
        editor.apply();
    }

    public OfflineGetCardSnTypeEmus getOfflineGetCardSnType() {
        return offlineGetCardSnType;
    }

    public void setOfflineGetCardSnType(OfflineGetCardSnTypeEmus offlineGetCardSnType) {
        this.offlineGetCardSnType = offlineGetCardSnType;
        editor.putInt("offlineGetCardSnType", offlineGetCardSnType.getValue());
        editor.apply();
    }

    public int getCardDataSector() {
        return cardDataSector;
    }

    public void setCardDataSector(int cardDataSector) {
        this.cardDataSector = cardDataSector;
        editor.putInt("cardDataSector", cardDataSector);
        editor.apply();
    }


    public CardSectorPassEmus getCardSectorPass() {
        return cardSectorPass;
    }

    public void setCardSectorPass(CardSectorPassEmus cardSectorPass) {
        this.cardSectorPass = cardSectorPass;
        editor.putInt("cardSectorPass", cardSectorPass.getValue());
        editor.apply();
    }

    public PrintDevEmus getPrintDevEmus() {
        return printDevEmus;
    }

    public void setPrintDevEmus(PrintDevEmus printDevEmus) {
        this.printDevEmus = printDevEmus;
        editor.putInt("printDev", printDevEmus.getValue());
        editor.apply();
    }

    public String getFixedAmount() {
        return fixedAmount;
    }

    public void setFixedAmount(String fixedAmount) {
        this.fixedAmount = fixedAmount;
        editor.putString("fixedAmount", fixedAmount);
        editor.apply();
    }

    public boolean isFixedAutoPay() {
        return fixedAutoPay;
    }

    public void setFixedAutoPay(boolean fixedAutoPay) {
        this.fixedAutoPay = fixedAutoPay;
        editor.putBoolean("fixedAutoPay", fixedAutoPay);
        editor.apply();
    }

    public int getPrintTextSize() {
        return printTextSize;
    }

    public void setPrintTextSize(int printTextSize) {
        this.printTextSize = printTextSize;
        editor.putInt("printTextSize", printTextSize);
        editor.apply();
    }

    public int getPrintWidthPixel() {
        return printWidthPixel;
    }

    public void setPrintWidthPixel(int printWidthPixel) {
        this.printWidthPixel = printWidthPixel;
        editor.putInt("printWidthPixel", printWidthPixel);
        editor.apply();
    }

    public int getPrintMiddleLocation() {
        return printMiddleLocation;
    }

    public void setPrintMiddleLocation(int printMiddleLocation) {
        this.printMiddleLocation = printMiddleLocation;
        editor.putInt("printMiddleLocation", printMiddleLocation);
        editor.apply();
    }

    public int getPrintProductNameEnter() {
        return printProductNameEnter;
    }

    public void setPrintProductNameEnter(int printProductNameEnter) {
        this.printProductNameEnter = printProductNameEnter;
        editor.putInt("printProductNameEnter", printProductNameEnter);
        editor.apply();
    }

    public int getDeviceReportFontSize() {
        return deviceReportFontSize;
    }

    public void setDeviceReportFontSize(int deviceReportFontSize) {
        this.deviceReportFontSize = deviceReportFontSize;
        editor.putInt("deviceReportFontSize", deviceReportFontSize);
        editor.apply();
    }

    public boolean isUseRefundBtn() {
        return isUseRefundBtn;
    }

    public void setUseRefundBtn(boolean isUseRefundBtn) {
        this.isUseRefundBtn = isUseRefundBtn;
        editor.putBoolean("isUseRefundBtn", isUseRefundBtn);
        editor.apply();
    }

    public int getFreeInputAmountFontSize() {
        return freeInputAmountFontSize;
    }

    public void setFreeInputAmountFontSize(int freeInputAmountFontSize) {
        this.freeInputAmountFontSize = freeInputAmountFontSize;
        editor.putInt("freeInputAmountFontSize", freeInputAmountFontSize);
        editor.apply();
    }

    public int getFreeTotalAmountFontSize() {
        return freeTotalAmountFontSize;
    }

    public void setFreeTotalAmountFontSize(int freeTotalAmountFontSize) {
        this.freeTotalAmountFontSize = freeTotalAmountFontSize;
        editor.putInt("freeTotalAmountFontSize", freeTotalAmountFontSize);
        editor.apply();
    }

    public boolean isShowRightKeyboard() {
        return isShowRightKeyboard;
    }

    public void setShowRightKeyboard(boolean showRightKeyboard) {
        this.isShowRightKeyboard = showRightKeyboard;
        editor.putBoolean("isShowRightKeyboard", showRightKeyboard);
        editor.apply();
    }

    public int getRightKeyboardDisplaySize() {
        return rightKeyboardDisplaySize;
    }

    public void setRightKeyboardDisplaySize(int rightKeyboardDisplaySize) {
        this.rightKeyboardDisplaySize = rightKeyboardDisplaySize;
        editor.putInt("rightKeyboardDisplaySize", rightKeyboardDisplaySize);
        editor.apply();
    }

    public int getInputNumberBottomButtonSize() {
        return inputNumberBottomButtonSize;
    }

    public void setInputNumberBottomButtonSize(int inputNumberBottomButtonSize) {
        this.inputNumberBottomButtonSize = inputNumberBottomButtonSize;
        editor.putInt("inputNumberBottomButtonSize", inputNumberBottomButtonSize);
        editor.apply();
    }
}
